package security;

import org.apache.log4j.Logger;

import util.Constants;

public class SecuritySimulator {
	final static Logger LOG = Logger.getLogger("SECURITY");
	final String admin = "aa";
	final String adminPass = "aaaa";
	final String approver = "bb";
	final String approverPass = "bbbb";
	final String viewer = "cc";
	final String viewerPass = "cccc";

	public boolean checkAdmin(String user, String pass) {
		if (user.equals(getAdmin()) && pass.equals(getAdminPass()))
			return true;
		else
			return false;
	}

	public boolean checkApprover(String user, String pass) {
		if (user.equals(getApprover()) && pass.equals(getApproverPass()))
			return true;
		else
			return false;
	}

	public int getRole(String user, String pass) {
		LOG.debug("USER: " + user);
		LOG.debug("PASSWORD: " + pass);
		if (checkAdmin(user, pass)) {
			LOG.debug("SECURITY.ADMIN");
			return Constants.ROLE_ADMIN;
		} else if (checkApprover(user, pass)) {
			LOG.debug("SECURITY.APPROVER");
			return Constants.ROLE_APPROVER;
		} else {
			LOG.debug("SECURITY.USER");
			return -1;
		}

	}

	public String getAdmin() {
		return admin;
	}

	public String getAdminPass() {
		return adminPass;
	}

	public String getApprover() {
		return approver;
	}

	public String getApproverPass() {
		return approverPass;
	}

	public String getViewer() {
		return viewer;
	}

	public String getViewerPass() {
		return viewerPass;
	}

}
